package com.TT.service.mq.kafka;

import com.alibaba.fastjson.serializer.JSONSerializer;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.listener.AcknowledgingMessageListener;
import org.springframework.kafka.support.Acknowledgment;

import java.util.Arrays;

/**
 * Created by 苏文广 on 2018/11/23
 */
//@Slf4j
//public class KafkaConsumerService implements AcknowledgingMessageListener<String, String> {
//
//    @Override
//    public void onMessage(ConsumerRecord<String, String> consumerRecord, Acknowledgment acknowledgment) {
//        System.out.println("----------------------");
//        if (log.isDebugEnabled()) {
//            log.debug("value:" + consumerRecord.value());
//            log.debug("topic:" + consumerRecord.topic());
//            log.debug("partition:" + consumerRecord.partition());
//            log.debug("offset:" + consumerRecord.offset());
//        }
//        try {
//            //TODO: 这里写消费逻辑
//            // 最后 调用acknowledgment的ack方法，提交offset
//            acknowledgment.acknowledge();
//        } catch (Exception ex) {
//            log.error("EventAsyncConsumer==Exception==>"+ex.getMessage()+ Arrays.toString(ex.getStackTrace()));
//        }
//
//
//
//    }
//}